﻿using System;
using System.Collections.Generic;
using System.Text;
using HHL_Acc.HHL_EntityAcc;
using HHL_Util;

namespace HHL_Acc.HHL_Util
{
    internal class AppInfo
    {
        private static string[,] _appTicketPrice = null;
        private static Dictionary<int, String> _appTicketType = null;
        private static Dictionary<int, String> _appVihicleType = null;
        public static GenLogins GenLogin;


        public static string[,] AppTicketPrice
        {
            get
            {
                if (_appTicketPrice != null)
                {
                    return _appTicketPrice;
                }
                return CommonBusUtil.GetTicketPrice();
            }
        }

        public static Dictionary<int, String> AppTicketType
        {
            get
            {
                if (_appTicketType != null)
                {
                    return _appTicketType;
                }
                return CommonBusUtil.GetTicketType();
            }
        }

        public static Dictionary<int, String> AppVihicleType
        {
            get
            {
                if (_appVihicleType != null)
                {
                    return _appVihicleType;
                }
                return CommonBusUtil.GetVehicleType();
            }
        }

        /// <summary>
        ///  Get Price of Ticket 
        /// </summary>
        /// <param name="ticketId"></param>
        /// <param name="vihicleId"></param>
        /// <returns></returns>
        public static String GetPriceFromTicket(int ticketId, int vihicleId)
        {
            try
            {
                long price = long.Parse(AppTicketPrice[ticketId, vihicleId]);

                CommonUtil.ConvertCurrencyToString(price);
            }
            catch (Exception e)
            {
                CommonUtil.WriteToLogFile(String.Format("Khong the convert {0} to String. \n {1} ",
                                                        AppTicketPrice[ticketId, vihicleId], e.Message));
            }
            return null;
        }

        /// <summary>
        /// Get Unicode Ticket 's name from ticket Id
        /// </summary>
        /// <param name="ticketId"></param>
        /// <returns></returns>
        public static String GetTicketName(int ticketId)
        {
            return CommonUtil.ConvertVni2Unicode(AppTicketType[ticketId]);
        }

        /// <summary>
        /// Get Unicode Vihicle 's name from vihicle Id
        /// </summary>
        /// <param name="vihicleId"></param>
        /// <returns></returns>
        public static String GetVihicleName(int vihicleId)
        {
            return CommonUtil.ConvertVni2Unicode(AppVihicleType[vihicleId]);
        }

        public static int[] GetIssueYear()
        {
            int currYear = DateTime.Now.Year;
            int pos = currYear - 5;
            int[] issueList = new int[10];
            while (pos < currYear - 5)
            {
                issueList[pos] = pos;
                pos++;
            }
            return issueList;
        }
    }
}